/**
 * @param {number[]} nums
 * @param {number} k
 * @param {number} x
 * @return {number[]}
 */
var getSubarrayBeauty = function (nums, k, x) {
  let left=0
  let right=left+k,res=[]
  while(right<nums.length+1){
    let arr = nums.slice(left,right)
    arr.sort((a,b)=>a-b)
    if(arr[x-1]<0){
      res.push(arr[x-1])
    }else res.push(0)

    left++
    right++
  }
  return res
};

getSubarrayBeauty([1,-1,-3,-2,3],3,2)